package cn.source.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import cn.source.domain.WarmHeartStation;
import cn.source.service.IWarmHeartStationService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.source.common.annotation.Log;
import cn.source.common.core.controller.BaseController;
import cn.source.common.core.domain.AjaxResult;
import cn.source.common.enums.BusinessType;
import cn.source.common.utils.poi.ExcelUtil;
import cn.source.common.core.page.TableDataInfo;

/**
 * 暖心驿站信息Controller
 *
 * @author zz
 * @date 2024-12-26
 */
@RestController
@RequestMapping("/system/station")
public class WarmHeartStationController extends BaseController
{
    @Autowired
    private IWarmHeartStationService warmHeartStationService;

    /**
     * 查询暖心驿站信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(WarmHeartStation warmHeartStation)
    {
        startPage();
        List<WarmHeartStation> list = warmHeartStationService.selectWarmHeartStationList(warmHeartStation);
        return getDataTable(list);
    }

    /**
     * 获取暖心驿站信息详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(warmHeartStationService.selectWarmHeartStationById(id));
    }

    /**
     * 新增暖心驿站信息
     */
    @PreAuthorize("@ss.hasPermi('system:station:add')")
    @Log(title = "暖心驿站信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WarmHeartStation warmHeartStation)
    {
        return toAjax(warmHeartStationService.insertWarmHeartStation(warmHeartStation));
    }

    /**
     * 修改暖心驿站信息
     */
    @PreAuthorize("@ss.hasPermi('system:station:edit')")
    @Log(title = "暖心驿站信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WarmHeartStation warmHeartStation)
    {
        return toAjax(warmHeartStationService.updateWarmHeartStation(warmHeartStation));
    }

    /**
     * 删除暖心驿站信息
     */
    @PreAuthorize("@ss.hasPermi('system:station:remove')")
    @Log(title = "暖心驿站信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(warmHeartStationService.deleteWarmHeartStationByIds(ids));
    }

    /**
     * 导出暖心驿站信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:station:export')")
    @Log(title = "暖心驿站信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WarmHeartStation warmHeartStation)
    {
        List<WarmHeartStation> list = warmHeartStationService.selectWarmHeartStationList(warmHeartStation);
        ExcelUtil<WarmHeartStation> util = new ExcelUtil<WarmHeartStation>(WarmHeartStation.class);
        util.exportExcel(response, list, "暖心驿站信息数据");
    }
}
